package com.liuchuanzheng.lcz_wanandroid.net.common

import com.liuchuanzheng.lcz_wanandroid.net.base.BaseResultBean


/**
 * @author 刘传政
 * @date 2021/5/25 15:52
 * QQ:1052374416
 * 电话:18501231486
 * 作用:这里时项目具体的网络返回基类。
 * 注意事项:
 */
class CommonResultBean<T> : BaseResultBean {
    var errorCode = 0
    var errorMsg: String = ""
    var data: T? = null
    override fun getAppCode(): Int {
        return errorCode
    }

    override fun getAppMsg(): String {
        return errorMsg
    }

    override fun isServerResultOK(): Boolean {
        return errorCode == 0
    }

    /**
     * data有值并且 服务器告知结果正确
     */
    fun checkDataNotNull(): Boolean {
        return data != null && isServerResultOK()
    }

    override fun toString(): String {
        return "CommonResultBean(errorCode=$errorCode, errorMsg='$errorMsg', data=$data)"
    }


}